var array=[1,2,2,1,3,4,4,5,1,2]
function unique(array){
    var res=[]
    for(let i =0;i<array.length;i++){
        var current=array[i]
        if(res.indexOf(current)===-1){
            res.push(current)
        }
    }
    return res
}

console.log(unique(array))
console.log([...new Set(array)]);
